<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>盒子模型-外边距特性</title>
    <style>
        .box1{
            width: 400px;
            height: 400px;
            background: red;
        }
        .box2{
            width: 200px;
            height: 200px;
            background: yellow;
            margin-top: 100px;
        }

        .box3{
            width: 400px;
            height: 300px;
            background: red;
            padding-top: 100px;
        }
        .box4{
            width: 200px;
            height: 200px;
            background: yellow;
        }

        .box5{
            width: 398px;
            height: 398px;
            background: red;
            /* 透明边框 */
            border: 1px solid transparent;
        }
        .box6{
            width: 200px;
            height: 200px;
            background: yellow;
            margin-top: 100px;
        }

        .box7{
            width: 400px;
            height: 400px;
            background: red;
        }
        .box8{
            width: 200px;
            height: 200px;
            background: yellow;
            margin-top: 100px;
            float: left;
        }

        .box9{
            width: 400px;
            height: 400px;
            background: red;
            /** 内部怎么折腾 不影响父盒子 */
            overflow: hidden;
        }
        .box10{
            width: 200px;
            height: 200px;
            background: yellow;
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <!-- 当父子关系时候 子盒子加外边距 作用到了父盒子-->
    <div class="box1">
        <div class="box2"></div>
    </div>
    <hr>
    <!-- 解决方式1 在父盒子上面加padding-top -->
    <div class="box3">
        <div class="box4"></div>
    </div>
    <hr>
    <!-- 解决方式2 在父盒子设置边框 -->
    <div class="box5">
        <div class="box6"></div>
    </div>
    <hr>
    <!-- 解决方式3 浮动父盒子或者子盒子 -->
    <div class="box7">
        <div class="box8"></div>
    </div>
    <hr>
    <!-- 解决方式4 父盒子加overflow:hidden -->
    <div class="box9">
        <div class="box10"></div>
    </div>      
</body>
</html>